@import java.util.*;

@args(String packageName, String className, List<Map<String, Object>> tableColumns)

package @(packageName).controller;

import com.thinker.framework.framework.ThinkerAdmin;
import com.thinker.framework.token.extend.ThinkerController;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

@@Slf4j
@@RestController
@@RequestMapping(value = "/__PATH__/@(className.toLowerCase())")
public class @(className)Controller extends ThinkerController {

    @@RequestMapping(value = "/@(className.toLowerCase()).vue")
    public String @(className.toLowerCase())()  {
        return ThinkerAdmin.table(thinkerTable -> {
            thinkerTable.setApi("/restful/__PATH__/@(className.toLowerCase())").setEditUrl("/__PATH__/@(className.toLowerCase())Edit.vue");

            thinkerTable.column("id", "id");
    @for (Map<String, Object> item : tableColumns) {
        @if(!item.get("name").equals("id") && !item.get("name").equals("createTime") && !item.get("name").equals("updateTime")) {
            thinkerTable.column("@(item.getOrDefault("name", ""))", "@(item.getOrDefault("fieldName", ""))");
        }
    }
            thinkerTable.column("op", "操作").edit().delete().setWidth("180px");

            thinkerTable.toolbar().add().delete().defaultTools();
        }).page().toString();
    }

    @@RequestMapping(value = "/@(className.toLowerCase())Edit.vue")
    public String @(className.toLowerCase())Edit() {
        return ThinkerAdmin.form(thinkerForm -> {
    @for (Map<String, Object> item : tableColumns) {
        @if(!item.get("name").equals("id") && !item.get("name").equals("createTime") && !item.get("name").equals("updateTime")) {
            thinkerForm.input("@(item.getOrDefault("name", ""))", "@(item.getOrDefault("fieldName", ""))");
        }
    }
        }).setSubmitUrl("/restful/__PATH__/@(className.toLowerCase())").page().toString();
    }
}
